<script setup>
import {ref} from "vue";
import {useConfirm} from "@/store/DialogConfirmStore";

const emits = defineEmits(['confirm'])
const messageStore = useConfirm();
const msg_pop = messageStore.msg;

const msg = ref();
const onChange = function (confirm) {
  emits('confirm', confirm)
}
messageStore.$subscribe((mutation, state) => {
  if (!msg.value) {
    return
  }
  console.log(messageStore)
  msg.value.open();
})
</script>

<template>
  <uni-popup ref="msg" type="dialog">
    <uni-popup-dialog
      :type="msg_pop.type"
      :title="msg_pop.title"
      :content="msg_pop.msg"
      confirm-text="确定"
      cancel-text="取消"
      @close="onChange(0)"
      @confirm="onChange(1)"
    >
    </uni-popup-dialog>
  </uni-popup>
</template>

<style scoped lang="scss">
</style>
